/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.me.marble;

import android.view.*;
import android.widget.*;

import android.os.Bundle;
import android.app.Activity;
import android.graphics.Color;
import android.content.Context;

/**
 *
 * @author tungi
 */

public class Options extends Activity{
    private int current_view;

    private MainOptionsMenu main_options;
    private GraphicsOptions graphics_options;
    private ControlSettings control_settings;

    @Override
    public void onCreate(Bundle cycle){
        super.onCreate(cycle);
        
        main_options=new MainOptionsMenu(this);
        graphics_options=new GraphicsOptions(this);
        control_settings=new ControlSettings(this);
        current_view=R.layout.optionsmain;
    }

    @Override
    public void onResume(){
        super.onStart();
        switch(current_view){
            case R.layout.optionsmain: main_options.createView();break;
            case R.layout.graphicsoptions: graphics_options.createView();break;
            case R.layout.controlsettings: control_settings.createView();break;
            case R.layout.informationmenu: setContentView(R.layout.informationmenu);break;
            default: break;
        }
    }

    public void changeView(int viewID){
        if(viewID==R.layout.graphicsoptions){
            graphics_options.createView();
            current_view=R.layout.graphicsoptions;
        }
        else if(viewID==R.layout.controlsettings){
            control_settings.createView();
            current_view=R.layout.controlsettings;
        }
        else if(viewID==R.layout.informationmenu){
            current_view=R.layout.informationmenu;
            setContentView(R.layout.informationmenu);
            ScrollView layout=(ScrollView)findViewById(R.information.layout);
            layout.setBackgroundColor(Color.WHITE);
            layout.setBackgroundDrawable(new BackgroundImage(this,
                       R.drawable.background_information,Color.WHITE));
        }
    }

    @Override
    public boolean onKeyDown(int keyCode,KeyEvent event){
        if(keyCode==KeyEvent.KEYCODE_BACK){
            if(current_view==R.layout.optionsmain)
                finish();
            else if(current_view==R.layout.graphicsoptions ||
                    current_view==R.layout.controlsettings ||
                    current_view==R.layout.informationmenu){
                main_options.createView();
                current_view=R.layout.optionsmain;
            }
            return true;
        }        
        else
            return super.onKeyDown(keyCode,event);
    }

    public View getAlertDialogView(String text){
        LayoutInflater inflater=(LayoutInflater)
                getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View row=inflater.inflate(R.layout.alertdialogview,null);

        TextView tv=(TextView)row.findViewById(R.text.label);
        tv.setBackgroundColor(android.graphics.Color.BLACK);
        tv.setText(text);

        return row;
    }
}
